home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_10_01 / 1001127b < prev    next >
Text File  |  1991-11-17  |  647b  |  33 lines

  1. #include <iostream.h>
  2. #include <conio.h>
  3.  
  4.  
  5. class Conbuf : public streambuf
  6.         {
  7.         int do_sputn(const char *s,int n);
  8.         int overflow(int=EOF);
  9.         } conbuf;
  10.  
  11. int Conbuf::overflow(int c)
  12.         {
  13.         do_sputn((char *)&c,1);
  14.         return 1;
  15.         }
  16.  
  17. int Conbuf::do_sputn(const char *s,int n)
  18.         {
  19.         int n1=n;
  20.         while (n1--)
  21.                 {
  22.                 putch(*s);
  23.                 if (*s++=='\n')
  24.                   {
  25.                   putch('\r');
  26.                   clreol();
  27.                   }
  28.                 }
  29.         return n;
  30.         }
  31.  
  32. ostream conout=&conbuf;
  33.